/*
Disclaimer of Warranty: THE PACKAGE IS PROVIDED
BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS'
AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT
ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW.
UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF
THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


(c) Copyright 2013 Edward Principe
All Rights Reserved

*/
#ifndef VARNODE_H
#define VARNODE_H

#include <Windows.h>
#include <tchar.h>
#include <fstream>
#include <list>
#include <vector>
#include <string>
#include <cantwritefile.h>
#include "vartype.h"

using namespace std;

////////////////////////////////////////////////////////////////
// VarNode: A structure representing a variable
////////////////////////////////////////////////////////////////
struct VarNode
{
public: // Construction
	VarNode()
	{
		Init();
	}

	VarNode(const VarNode& rhs)
	{
		Init();
		Copy(rhs);
	}

	~VarNode()
	{
		delete[] bound;
	}

public: // Attributes
	TYPE_STRING label; // Label
	TYPE_STRING object_label; // Object label

	VarType type; // Type
	bool is_stack; // True if allocated on stack

	TYPE_WORD offset; // Offset

	TYPE_WORD dim; // Dimensions
	TYPE_WORD *bound; // Boundry

	list<VarNode> list_struct; // A structure list

	vector<VarNode> objects;

	static TYPE_WORD offset_global; // Global offset
	static TYPE_WORD stack_offset; // Offset relitive to stack

public: // Methods
	void Reset(); // Resets structure

public: // Methods
	void WriteRelease(fstream& out); // Outputs release version
	void WriteDebug(fstream& out); // Outputs debug info

public: // Operator
	VarNode& operator = (const VarNode& rhs)
	{
		Copy(rhs);
		return *this;
	}

private: // Methods
	void Init(); // Iniatilizes class
	void Copy(const VarNode& rhs); // Copies class
};
#endif